home *** CD-ROM | disk | FTP | other *** search
/ PC Open 107 / PC Open 107 CD 1.bin / CD1 / INTERNET / COPIA SITI / Getleft / getleft-setup-notcl.exe / {app} / scripts / getWizard.tcl < prev    next >
Encoding:
Text File  |  2004-03-11  |  6.2 KB  |  206 lines

  1. ###############################################################################
  2. ###############################################################################
  3. ##                              getWizard.tcl
  4. ###############################################################################
  5. ###############################################################################
  6. ## Includes procedures to implement the configuration wizard, it was created 
  7. ## using tkwizard and tkwizthing by Bryan Oakley oakley_at_bardo.clearlight.com
  8. ###############################################################################
  9. ###############################################################################
  10. ## (c) 2001-2003 AndrΘs Garcφa Garcφa. fandom@retemail.es
  11. ## Distributed under the terms of the GPL v2
  12. ###############################################################################
  13. ###############################################################################
  14.  
  15. source [file join $dirGetleft(scripts) tkwizard.tcl]
  16.  
  17. tkwizard::tkwizard .wizard -title {Configure Getleft}
  18.  
  19. .wizard eval {
  20.     variable wizData
  21.     variable logo
  22.  
  23.     # default values
  24.     if {[info exists wizData]} {
  25.         unset wizData
  26.     }
  27.  
  28.     set logo [image create photo \
  29.             -file [file join "$dirGetleft(doc)" logo.gif]]
  30.  
  31.     bind .wizard <<WizCancel>> "
  32.         tkwizard::.wizard::checkCancel
  33.         break
  34.     "
  35. }
  36.  
  37. .wizard step {Language} -layout basic {
  38.     global   getleftOptions supportedLang
  39.     variable wizData
  40.  
  41.     set c [$this widget clientArea]
  42.  
  43.     foreach lang $supportedLang(langList) {
  44.         set radio($lang) [radiobutton $c.radio$lang -text $lang   \
  45.                 -value $supportedLang($lang)                      \
  46.                 -variable getleftOptions(lang)                    \
  47.                 -command "tkwizard::.wizard::changeLanguage $supportedLang($lang)"]
  48.     }
  49.  
  50.     if {![info exists getleftOptions(lang)]} {
  51.         set getleftOptions(lang) en
  52.     }
  53.     changeLanguage $getleftOptions(lang)
  54.  
  55.     set i 0
  56.     set j 0
  57.     foreach lang $supportedLang(langList) {
  58.         grid $radio($lang) -padx 5 -row $i -column $j -sticky w
  59.         incr j
  60.         if {$j==3} {
  61.             set j 0
  62.             incr i
  63.         }
  64.     }
  65.     return
  66. }
  67.             
  68. .wizard step {Proxy} -layout basic {
  69.     variable wizData
  70.     global   confWizardLabels
  71.  
  72.     set c [$this widget clientArea]
  73.     $this stepconfigure                                     \
  74.         -title    $confWizardLabels(proxTitle)              \
  75.         -subtitle $confWizardLabels(proxSub)                \
  76.         -pretext  {}                                        \
  77.         -posttext {}
  78.  
  79.     Herramientas::ConfProxyWindowCommon $c
  80.  
  81.  
  82.     set useEvent <<WizFinish>>
  83.     if {$::getleftState(os)=="unix"} {
  84.         set useEvent <<WizNextStep>>
  85.     }
  86.     bind .wizard $useEvent "
  87.         [namespace current]::proxyControl %W $useEvent
  88.         break
  89.     " 
  90.  
  91.     return
  92. }
  93.  
  94. if {$::getleftState(os)=="unix"} {
  95.     .wizard step {Browser} -layout basic {
  96.         variable wizData
  97.         global   confWizardLabels
  98.  
  99.         set c [$this widget clientArea]
  100.         $this stepconfigure                                 \
  101.             -title    $confWizardLabels(browTitle)          \
  102.             -subtitle $confWizardLabels(browSub)            \
  103.             -pretext  {}                                    \
  104.             -posttext {}
  105.  
  106.         Ayuda::ChooseLinuxBrowserCommon $c
  107.  
  108.         bind .wizard <<WizFinish>> "
  109.             [namespace current]::browserControl %W
  110.             break
  111.         "
  112.         return
  113.     }
  114. }
  115.  
  116. ################################################################################
  117. # proxyControl
  118. #     Invokes the procedure that checks that the data entered for the proxy
  119. #     is consistent.
  120. #
  121. # Parameter
  122. #     W: The wizard window as returned by the event.
  123. #     event: Whether we finish with this or not
  124. ################################################################################
  125. proc tkwizard::.wizard::proxyControl {W useEvent} {
  126.  
  127.     set exitCode [::Herramientas::ConfProxyControl accept $W]
  128.     if {$exitCode==0} {
  129.         tkwizard::handleEvent $W $useEvent
  130.         if {$useEvent=="<<WizFinish>>"} {
  131.             destroy .wizard
  132.         }
  133.     }
  134.  
  135.     return
  136. }
  137.  
  138. ################################################################################
  139. # browserControl
  140. #     Checks whether all is well with the chose browser.
  141. #
  142. # Parameter
  143. #     W: The wizard window as returned by the event.
  144. #     event: Whether we finish with this or not
  145. ################################################################################
  146. proc tkwizard::.wizard::browserControl {W} {
  147.  
  148.     set exitCode [::Ayuda::ChooseLinuxBrowserControl 1 $W]
  149.     if {$exitCode==0} {
  150.         destroy .wizard
  151.     }
  152.  
  153.     return
  154. }
  155.  
  156. ################################################################################
  157. # changeLanguage
  158. #     When the user click on one of the language options, this procedure takes
  159. #     care of actually changing the texts.
  160. #
  161. # Parameter
  162. #     lan: code of the language, 'es', 'en', ...
  163. ################################################################################
  164. proc tkwizard::.wizard::changeLanguage {lan} {
  165.     global confWizardLabels getleftOptions
  166.     variable logo
  167.  
  168.     ReadLangFile $lan
  169.  
  170.     wm title .wizard $confWizardLabels(title)
  171.  
  172.     .wizard stepconfigure                                   \
  173.         -title    $confWizardLabels(lanTitle)               \
  174.         -subtitle $confWizardLabels(lanSub)                 \
  175.         -icon     $logo                                     \
  176.         -pretext  {}                                        \
  177.         -posttext {}
  178.  
  179.     return
  180. }
  181.  
  182. ################################################################################
  183. # checkCancel
  184. #     When the user click on cancel or tries to close the window, we will first
  185. #     check that he really means it.
  186. ################################################################################
  187. proc tkwizard::.wizard::checkCancel {} {
  188.     global confWizardLabels
  189.  
  190.     set what [tk_messageBox -type yesno -icon question -parent .wizard \
  191.             -message $confWizardLabels(sureMssg)                       \
  192.             -title $confWizardLabels(sureTitle)]
  193.  
  194.     if {$what!="no"} {
  195.         exit
  196.     }
  197.  
  198.     focus .wizard
  199.     return
  200. }
  201.  
  202.  
  203. .wizard show
  204. tkwait window .wizard 
  205.             
  206.